﻿using System.Collections.Generic;
using System.Linq;
using JetBrains.ReSharper.Psi.CSharp.Tree;
using Twins.Infrastructure;
using Twins.Interface;
using Twins.Interface.IHandler;
namespace Twins.Classes.Hanlder.HanlderStatement
{
    public class HandlerForISwitchStatement : IHandler<ISwitchStatement>
    {

        public IEnumerable<ILineCode> DoFor(ISwitchStatement switchStatement)
        {
            var receiveHashLineCodeFromProcesserCSharpStatement = IoC
                .Resolve<IReceiveHashLineCodeFromProcesserCSharpStatement>();
            string hashLineCode = switchStatement.SwitchKeyword.GetText();
            
            var receiveHashLineCodeFromProcesserCSharpExpression = IoC
                .Resolve<IReceiveHashLineCodeFromProcesserCSharpExpression>();

            receiveHashLineCodeFromProcesserCSharpExpression
                .ReceiveHashLineCode(switchStatement.Condition, ref hashLineCode);

            return receiveHashLineCodeFromProcesserCSharpStatement
                .ReceiveHashLineCode(switchStatement, switchStatement.Block, hashLineCode); 
        }


        public IEnumerable<ILineCode> DoFor(object obj)
        {
            return DoFor((ISwitchStatement)obj);
        }

    }
}